home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource4 / 280_01 / expand.c < prev    next >
Text File  |  1989-01-13  |  2KB  |  63 lines

  1. /* [expand.c of JUGPDS Vol.46] */
  2. /*
  3. *****************************************************************
  4. *                                *
  5. *    Written by  Hakuo Katayose (JUG-CP/M No.179)        *
  6. *            49-114 Kawauchi-Sanjuunin-machi        *
  7. *            Sendai, Miyagi 980                          *
  8. *            Phone: 0222-61-3219                *
  9. *                                *
  10. *       Modifird by Toshiya Oota   (JUG-CPM No.10)              *
  11. *                   Sakae ko-po 205                 *
  12. *            5-19-6 Hosoda                *
  13. *            Katusikaku Tokyo 124            *
  14. *                                *
  15. *        for MS-DOS Lattice C V3.1J & 80186/V20/V30    *
  16. *                                *
  17. *    Compiler Option: -ccu -k0(1) -ms -n -v -w        *
  18. *                                *
  19. *    Edited & tested by Y. Monma (JUG-CP/M Disk Editor)    *
  20. *            &  T. Ota   (JUG-CP/M Sub Disk Editor)    *
  21. *                                *
  22. *****************************************************************
  23. */
  24.  
  25. /* Library functions for Software Tools */
  26.  
  27. #include "stdio.h"
  28. #include "dos.h"
  29. #include "ctype.h"
  30. #include "tools.h"
  31.  
  32. /*  expand - uncompress standard input */
  33.  
  34. #define    RCODE        127
  35.  
  36. void    main(argc,argv)
  37. int    argc;
  38. char    *argv[];
  39.  
  40. {
  41.     int    c, code;
  42.  
  43.     while ((code = getchar()) != EOF)
  44.         if (code == RCODE) {
  45.             if ((c = getchar()) == EOF)
  46.                 break;
  47.             if ((code = getchar()) == EOF)
  48.                 break;
  49.             code -= '0';
  50.             while (code--)
  51.                 putchar(c);
  52.         } else {
  53.             code -= '0';
  54.             while (code--) {
  55.                 if ((c = getchar()) == EOF)
  56.                     break;
  57.                 putchar(c);
  58.                 }
  59.             if ( c == EOF )
  60.                 break;
  61.             }
  62. }
  63.